package br.odb.bzk3.android;

import java.util.ArrayList;
import java.util.Vector;

/***
 * 
 * @author monty
 *
 */
public class AudioManager {
	// ------------------------------------------------------------------------------------------------------------
	/**
	 * 
	 */
	private static AudioManager instance;
	/**
	 * 
	 */
	private ArrayList<PositionalMediaPlayer> audioPlayers = new ArrayList<PositionalMediaPlayer>();
	/**
	 * 
	 */
	private GameActor listener;	
	// ------------------------------------------------------------------------------------------------------------
	/**
	 * 
	 * @return
	 */
	public static AudioManager getInstance() {

		if (instance == null)
			instance = new AudioManager();

		return instance;
	}
	// ------------------------------------------------------------------------------------------------------------
	/**
	 * 
	 * @param pmp
	 */
	public void registerPlayer(PositionalMediaPlayer pmp) {
		audioPlayers.add(pmp);
	}
	// ------------------------------------------------------------------------------------------------------------
	/**
	 * 
	 * @param listener
	 */
	public void setListener(GameActor listener) {
		this.listener = listener;
	}
	// ------------------------------------------------------------------------------------------------------------
	/**
	 * 
	 */
	public void update() {
		int size = audioPlayers.size();
		for (int c = 0; c < size; ++c)
			((PositionalMediaPlayer) audioPlayers.get(c)).update(listener
					.getPosition());
	}
	// ------------------------------------------------------------------------------------------------------------	
}
